package com.shanjupay.merchant.controller;

import com.shanjupay.common.util.RedisUtil;
import com.shanjupay.common.util.SpeechRecognizerDemo;
import com.shanjupay.common.util.TimeUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.beans.factory.annotation.Value;

import javax.annotation.Resource;


/**
 * @author Administrator
 * @version 1.0
 **/

@Api(value = "商户平台-应用管理", tags = "商户平台-应用相关")
@RestController
public class TimeController {

    @Value("${xuzhon.alinls.appKey}")
    private String appKey;

    @Value("${xuzhon.alinls.appToken}")
    private String appToken;


    @ApiOperation("时间词提炼")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "", value = "时间", required = true, dataType = "string" )})
    @PostMapping(value = "/gettime/")
    public String getTextToTime(){

        String text = "过6分钟59秒后提醒我";
        String timeUtil =  TimeUtil.getTimeArr(text);
        return timeUtil;
    }



    /**
     * 把语音转换为文字输出
     *
     * @param vedioUrl
     *
     * @return
     */
    public static String nlsToText(String vedioUrl) {

        String appKey = "JaqolRSDWKXA3CST";
        String token = "dab66755d14f49219c3917d8239c64d5";
        String url = ""; // 默认即可，默认值：wss://nls-gateway.cn-shanghai.aliyuncs.com/ws/v1

        SpeechRecognizerDemo demo = new SpeechRecognizerDemo(appKey, token, url);
        // TODO 重要提示： 这里用一个本地文件来模拟发送实时流数据，实际使用时，用户可以从某处实时采集或接收语音流并发送到ASR服务端
        //demo.process("./nls-sample-16k.wav", 16000);
        demo.process("./test.wav", 16000,"");
        //demo.process("./nls-sample.opus", 16000);
        demo.shutdown();
        return "";
    }








}
